package com.cgsd.heyu.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;

import com.android.library.adapter.BaseMultiItemAdapter;
import com.android.library.adapter.ViewHolder;
import com.android.library.utils.TimeUtil;
import com.cgsd.heyu.R;
import com.cgsd.heyu.entity.AbonusTeamEntity;
import com.cgsd.heyu.entity.VipEntity;
import com.cgsd.heyu.utils.FormatUtil;

import java.util.List;

/**
 * @author xiaoxing
 * Description 区域用户详情
 * CreateData: 2021/1/7
 */
public class AbonusTeamAdapter extends BaseMultiItemAdapter<AbonusTeamEntity> {

    public AbonusTeamAdapter(Context mContext, List<AbonusTeamEntity> mDatas) {
        super(mContext, mDatas);
    }

    @Override
    protected int muItemViewType(int position, AbonusTeamEntity abonusTeamEntity) {
        return 0;
    }

    @Override
    protected int muLayoutId(int itemType) {
        return R.layout.item_abonus_team;
    }

    @Override
    public void convert(ViewHolder holder, AbonusTeamEntity abonusTeamEntity, int position) {
        View line = holder.getView(R.id.view_line);
        holder.setText(R.id.tv_phone, FormatUtil.getPhone(abonusTeamEntity.mobileNo));
        holder.setText(R.id.tv_area,abonusTeamEntity.area.replace(" ","\n"));
      //        holder.setText(R.id.tv_level,"V"+vipEntity.vipLevel+"(有效:V"+vipEntity.vipLevel+")");

        Log.e("***************", abonusTeamEntity.vipLevel);
        if (abonusTeamEntity.vipLevel.equals("0")) {
            holder.setText(R.id.tv_level,"普通用户");
        } else if (abonusTeamEntity.vipLevel.equals("1")) {
            holder.setText(R.id.tv_level,"VIP");
        } else if (abonusTeamEntity.vipLevel.equals("2")) {
            holder.setText(R.id.tv_level,"合伙人");
        } else if (abonusTeamEntity.vipLevel.equals("3")) {
            holder.setText(R.id.tv_level,"董事");
        }
        String time = TimeUtil.dateString(abonusTeamEntity.registerTime/1000,"yyyy-MM-dd HH:mm:ss");
        time = time.substring(2);
        holder.setText(R.id.tv_time,time.replace(" ","\n"));
        if (position == mDatas.size() - 1){
            line.setVisibility(View.GONE);
        }else {
            line.setVisibility(View.VISIBLE);
        }
    }
}
